//
//  EditPlanner.m
//  Bespoke
//
//  Created by Cheng on 12/10/4.
//
//

#import "EditPlanner.h"

@implementation EditPlanner
@synthesize Tf_PlannerName, Tf_PlannerEmail, Bt_Cancel, Bt_Done;
@synthesize delegate;

- (IBAction)CancelPressed:(id)sender {
    [delegate CancelPressed_EditPlanner];
}

- (IBAction)DonePressed:(id)sender {
    
    if ([Tf_PlannerName.text isEqualToString:@""]) {
        UIAlertView *AlertView = [[UIAlertView alloc]initWithTitle:@"Alert" message:@"Name is null." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
        [AlertView show];
        return;
    }
    if ([Tf_PlannerEmail.text isEqualToString:@""]) {
        UIAlertView *AlertView = [[UIAlertView alloc]initWithTitle:@"Alert" message:@"Email is null." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
        [AlertView show];
        return;
    }
    else if ([Tf_PlannerEmail.text rangeOfString:@"@"].location == NSNotFound) {
        UIAlertView *AlertView = [[UIAlertView alloc]initWithTitle:@"Alert" message:@"The Email you entered is incorrect." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
        [AlertView show];
        return;
    }
    [delegate SavePlannerInfo:Tf_PlannerName.text SetPlannerEmail:Tf_PlannerEmail.text];
}

@end
